package zhishu.iceyyy.com.bxq_2500.adapter;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import java.util.List;

import zhishu.iceyyy.com.bxq_2500.R;
import zhishu.iceyyy.com.bxq_2500.activity.Feedback_Activity;
import zhishu.iceyyy.com.bxq_2500.activity.ShouCangActivity;
import zhishu.iceyyy.com.bxq_2500.base.BaseApplication;
import zhishu.iceyyy.com.bxq_2500.base.Base_Z_Adapter;
import zhishu.iceyyy.com.bxq_2500.bean.Mine;
import zhishu.iceyyy.com.bxq_2500.myadapter.mys.MysViewAdapter;


/**
 * Created by 他的猫 on 2016/11/21.
 * 工作经历适配器
 */

public class My_Adapter extends Base_Z_Adapter {
    Context context;

    public My_Adapter(Context context) {
        this.context = context;

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        // 查找控件
        if (null == convertView) {
            convertView = LayoutInflater.from(BaseApplication.getInstance())
                    .inflate(R.layout.item_listview2, null);
            holder = new My_Adapter.Holder();


            holder.gv_images = (ListView) convertView
                    .findViewById(R.id.gv_images);


            // 缓存Holder
            convertView.setTag(holder);
        } else {
            holder = (My_Adapter.Holder) convertView.getTag();
        }

        Log.e(TAG, "xx" + position);
        List<Mine.DataBean.ListBean> nrowDataeme = (List<Mine.DataBean.ListBean>) getItem(position);


        initInfoImages(holder.gv_images, nrowDataeme);
        return convertView;
    }


    public class Holder {


        ListView gv_images;

    }

    MysViewAdapter nearByInfoImgsAdapter;

    /**
     * 加载信息中包含的图片内容
     *
     * @param listimg
     */
    public void initInfoImages(final ListView gv_images, final List<Mine.DataBean.ListBean> listimg) {


        nearByInfoImgsAdapter = new MysViewAdapter(BaseApplication.getInstance(), listimg);
        gv_images.setAdapter(nearByInfoImgsAdapter);

        gv_images.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Mine.DataBean.ListBean moviceBean = listimg.get(i);
                String vod_id = moviceBean.getM_mine_title();
                switch (vod_id) {
                    case "找片":
                        context.startActivity(new Intent(context, Feedback_Activity.class));
                        break;
                    case "观看记录":

                        break;
                    case "我的收藏":
                        context.startActivity(new Intent(context, ShouCangActivity.class));
                        break;
                    case "清除缓存":
                        Toast.makeText(context, "清除缓存", Toast.LENGTH_SHORT).show();

                        break;
                    case "意见反馈":
                        context.startActivity(new Intent(context, Feedback_Activity.class));

                        break;
                    default:
                        break;
                }
//                BaseApplication.getInstance().startActivity(new Intent(BaseApplication.getInstance(), Work_Activity.class).putExtra("value", vod_id));
            }
        });

    }
}
